//判断子序列
#include<iostream>
#include<algorithm>

using namespace std;

const int N = 100010;

int n, m, i, j;
int a[N], b[N];

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i ++) scanf("%d", &a[i]);
    for(int i = 0; i < m; i ++) scanf("%d", &b[i]);
    for(i = 0, j = 0; i < n;){
        while(j < m && a[i] != b[j]) j ++;
        if(a[i] == b[j]){
            i ++;
            j ++;
        }
        if(j == m) break;
    }
    if(i == n) cout << "Yes";
    else cout << "No";
    return 0;
}